package leetcode.秋招.腾讯.第二次;

import java.util.Scanner;

/**
 * @author ：zsy
 * @date ：Created 2021/9/26 20:01
 * @description：
 */
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int i = 0; i < T; i++) {
            int n = in.nextInt();
            int[] nums = new int[n];
            int[] dp = new int[n];
            for (int j = 0; j < nums.length; j++) {
                nums[j] = in.nextInt();
                dp[j] = nums[j];
            }
            int max = 0;
            for (int j = n - 1; j >= 0; j--) {
                int num = nums[j];
                if (num + j < n) {
                    dp[j] += dp[num + j];
                }
                max = Math.max(dp[j], max);
            }
            System.out.println(max);
        }
    }
}
